<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE HTML>
<body>
    <link href="${staticUrl_ }/css/plugins/treegrid/jquery.treegrid.css" rel="stylesheet">
    
	<div class="col-lg-12">
		<div class="ibox float-e-margins">
			<div class="ibox-title">
				<h5>Basic Data Tables example with responsive plugin</h5>
			</div>
			<div class="ibox-content">

				<div class="dataTables_wrapper form-inline">
					
					<table class="table tree" id="resourceTree">
						<c:forEach var="data" items="${treeList}" varStatus="vs">
							<tr class="treegrid-${data.id } treegrid-parent-${data.parentId }">
			                    <td><a href="${context_ }/${moduleName }/show/${data.id }">${data.text }</a></td>
			                    <td class="center"><button class="btn btn-info " type="button" onclick="onclickChange('${data.id}');"><i class="fa fa-paste"></i>修改</button></td>
			                </tr>
			                <c:if test="${fn:length(data.children) > 0}">
			                	<c:forEach var="data1" items="${data.children}" varStatus="vs1">
									<tr class="treegrid-${data1.id } treegrid-parent-${data1.parentId }">
					                    <td><a href="${context_ }/${moduleName }/show/${data1.id }">${data1.text }</a></td>
					                    <td class="center"><button class="btn btn-info " type="button" onclick="onclickChange('${data1.id}');"><i class="fa fa-paste"></i>修改</button></td>
					                </tr>
					                <c:if test="${fn:length(data1.children) > 0}">
					                	<c:forEach var="data2" items="${data1.children}" varStatus="vs2">
					                		<tr class="treegrid-${data2.id } treegrid-parent-${data2.parentId }">
							                    <td><a href="${context_ }/${moduleName }/show/${data2.id }">${data2.text }</a></td>
							                    <td class="center"><button class="btn btn-info " type="button" onclick="onclickChange('${data2.id}');"><i class="fa fa-paste"></i>修改</button></td>
							                </tr>
					                	</c:forEach>
					                </c:if>
			                	</c:forEach>
							</c:if>
						</c:forEach>
					</table>
					
				</div>

			</div>
		</div>
	</div>
    
    <!-- Data Tables -->
    <script src="${staticUrl_ }/js/plugins/treegrid/jquery.treegrid.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(document).ready(function() {
	        $('#resourceTree').treegrid();
	    });
		
		function onclickChange(id) {
			window.location.href = '${context_}/${moduleName}/edit/' + id;
		};
	</script>
</body>
</html>